home *** CD-ROM | disk | FTP | other *** search
- /* mousdemo.c */
-
- /* mouse driver demo by James B. Burks (1990) */
-
- /* released into the public domain by the author */
-
- /* for Borland's Turbo C 2.0 */
-
- #include <conio.h>
- #include <graphics.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- #include "mousedef.h"
-
- void checkgraph(void)
-
- {
-
- /* routine which checks the status of each graphics call and errors
- if it is not successful.
- */
- int gres;
-
- if ( (gres = graphresult()) != 0)
- {
- closegraph();
- printf("Graphics system error # %d which is: %s\n",
- gres, grapherrormsg(gres));
- exit(1);
- }
- }
-
- main()
-
- {
-
- int nb, graphmode, graphdriver = DETECT;
- int bstat, x, y;
- char line[60];
-
- initgraph(&graphdriver, &graphmode, "c:\\tc");
- checkgraph();
-
- outtextxy(0, 10, "Press any key to exit mouse demo.");
- outtextxy(0, 20, "Move mouse and/or click buttons.");
-
- nb = m_reset();
-
- if (nb == 0)
- {
- closegraph();
- printf("No mouse driver loaded!\nProgram Terminated.");
- exit(2);
- }
-
- m_show_cursor();
-
- while (!kbhit())
- {
-
- bstat = m_status(&x, &y);
-
- sprintf(line, "Button status: %d X position: %d Y position: %d",
- bstat, x, y);
-
- m_hide_cursor(); /* must hide cursor before drawing */
-
- cleardevice(); /* erase the screen */
-
- outtextxy(0, 10, "Press any key to exit mouse demo.");
- outtextxy(0, 20, "Move mouse and/or click buttons.");
-
- outtextxy(0, 30, line);
-
- m_show_cursor(); /* now show the cursor again */
-
- delay(500); /* wait 1/2 second */
-
- }
-
- getch();
-
- closegraph();
- checkgraph();
-
- }
-
- /* eof mousdemo.c */